﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;

namespace Jy123.Web.Friend
{
    public partial class Invite : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int userID;
            string strUserIdFromCookie = Common.Cookie.getCookie("UserID");
            if (string.IsNullOrEmpty(strUserIdFromCookie))
            {
                Response.Redirect("/");
            }
            userID = int.Parse(strUserIdFromCookie);

            //页面初始化
            StringBuilder sbHtml = new StringBuilder(Cache["user_friendinvite"].ToString());//最终写出页面的大sb
            sbHtml = sbHtml.Replace("$Header$", Cache["user_header"].ToString());//头部
            sbHtml = sbHtml.Replace("$Footer$", Cache["user_footer"].ToString());//底部
            sbHtml = sbHtml.Replace("$LeftUserCmd$", Cache["user_navigation_up"].ToString());//左侧导航
            sbHtml = sbHtml.Replace("$LeftUserFriendAdd$", Cache["user_friendadd"].ToString());//左侧直接添加好友
            //------------------------------------------------------------------------
            sbHtml = sbHtml.Replace("$InviteUrl$",InviteUrl(userID));
            Response.Write(sbHtml.ToString());
        }
        /// <summary>
        /// 邀请地址
        /// </summary>
        /// <param name="userID">邀请者ID</param>
        /// <returns>链接地址</returns>
        private string InviteUrl(int userID)
        {
            Jy123.Model.User_Main mUser = new Jy123.Model.User_Main();
            Jy123.BLL.User_Main bllUser = new Jy123.BLL.User_Main();
            mUser = bllUser.GetModel(userID);
            string strInviteCode = DBUtility.DESEncrypt.Encrypt(mUser.VerifyCode);
            return "http://www.Jy123.com/?InviteCode=" + strInviteCode;
        }
    }
}
